<?php
include 'include/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN"
"http://www.w3.org/tr/html4/loose.dtd">
<html>
  <head>
    <title>JoshHughes.com Hockey Pool</title>
	<link rel="stylesheet" href="http://hockey.joshhughes.com/css/hockey.css" type="text/css">
    <script src="http://hockey.joshhughes.com/scripts/prototype.js" type="text/javascript"></script>
	<script src="http://hockey.joshhughes.com/scripts/scriptaculous.js" type="text/javascript"></script>
	<script src="http://hockey.joshhughes.com/scripts/hockey.js" type="text/javascript"></script>
  </head>
<body>
<div id="pagewidth" >
	<div id="header" >
	
		<?PHP include_once("layout/header.html"); ?>
		
	</div>
			<div id="wrapper" class="clearfix" > 
			<div id="maincol" >

			<?
				$error="<p><b>There has been an error processing your activation.</b></p>\n
				<p>Please refer to the activation e-mail sent to you and click the enclosed link.</p>\n";
				
				if (isset($_GET['id']))
				{
					dbConnect();
					$SQL="UPDATE Users SET flag='1' WHERE md5(Email)='$_GET[id]'";
					@mysql_query($SQL) or captureCritalFail("MySQL Query Error in activate.php, line 32", mysql_error(), $userID, time(), $SQL);
					$num_rows = @mysql_affected_rows();
					if ($num_rows == 1)
					{
						echo "<p><b>Thank you for activating your account.</b></p>\n";
						echo "<p>You can now <a href=\"index.php\">play in the pool</a>!</p>\n";
					}
					else
					{
						$SQL="SELECT count(*) FROM Users WHERE flag='1' AND md5(Email)='".$_GET[id]."'";
						@mysql_query($SQL) or captureCritalFail("MySQL Query Error in activate.php, line 42", mysql_error(), $userID, time(), $SQL);
						$num_rows = mysql_affected_rows();
						if($num_rows == 1)
						{
							echo "<p><b>Your account has already been activated.</b></p>\n";
						}
						else
						{
							print $error;
						}
					}
				}
				else
				{
					print $error;
				}
				?>
			
			</div>
			<div id="leftcol" >
				<?PHP include_once("layout/left_column.php"); ?>
			</div>
			
		</div>
		
		<div id="footer" >
			<?PHP include_once("layout/footer.html"); ?>
		</div>
</div>
</body>
</html>